<?php
session_start(); 
if(!isset($_SESSION['userName'])){
header( 'location: index.php' ); 
}

include("../conf/connect.php");
	$user_id = $_SESSION['user_id'];
	
	$sql="select * from track WHERE user_id='$user_id' and status ='1' order by id desc";
	$result =mysql_query($sql) or die ("problem budget_heads");
	$data = mysql_fetch_array($result);
	$totalNumberOfRow = mysql_num_rows($result);
	
	
	if ($data['status'] == 1 ){
		$cp = $data['qid'];
		$_SESSION['lid']= $data['appid'];
		$_SESSION['usrHHid'] = $data['hid'];
		if(is_numeric($cp)){
			$ncp=$cp+1;
			if($cp == 8 )
		    	header( "location: qus7.php");
			else if($cp == 9 )
		    	header( "location: qus8.php");
			else if($cp == 7 )
		    	header( "location: qus4.php?serial=a");
			else
				header( "location: qus1.php?serial=$ncp");
		}
		else{
			$cdata = explode('_',$cp);
			$cdt=count($cdata);
			if($cdt==1){
				
			}
			else if($cdt==2){
				$qstr = "serial=".$cdata[1];
			}
			else if($cdt==3){
				$qstr = "serial=".$cdata[1].$cdata[2];
			}
			else if($cdt>3){
				$cqdata = explode(':',$cp);
				$qstr = "serial=".$cdata[1].$cqdata[1];
			}
			if($cp =='rel_detail')
				header( "location: rel_detail.php");
			else if($cp =='g')
				header( "location: qus4.php?serial=a");
			else if($cdata[0] =='hc')
				header( "location: hc_info.php?".$qstr);
			else
				header( "location: qus4.php?serial=b");
		}
	}
	else{
		header( 'location:index2.php?con=no' );
	}
  
?>